<template>
  <el-dialog v-model="techSearchVisible" title="Shipping address">
    <el-form :model="search">
      <el-form-item label="检查编码">
        <el-input v-model="search.techCode"/>
      </el-form-item>
      <el-form-item label="检查名称">
        <el-input v-model="search.techName"/>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleSearch">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tech_list" ref="techSearchTable">
      <el-table-column type="selection"/>
      <el-table-column prop="techCode" label="检查编码"/>
      <el-table-column prop="techName" label="检查名称"/>
      <el-table-column prop="techFormat" label="检查规格"/>
      <el-table-column prop="techPrice" label="单价"/>
      <el-table-column prop="priceType" label="费用分类"/>
    </el-table>
    <template #footer>
                <span class="dialog-footer">
                  <el-button @click="cancel">
                    Cancel
                  </el-button>
                  <el-button type="primary" @click="confirm">
                    Confirm
                  </el-button>
                </span>
    </template>
  </el-dialog>
</template>

<script>
import axios from 'axios'

export default {
  name: "MedicalTechnologySearchView",
  data() {
    return {
      search: {
        techCode: '',
        techName: ''
      },
      tech_list: []
    }
  },
  methods: {
    cancel() {
      this.store.commit("setTechSearchVisible", false)
    },
    confirm() {
      this.$bus.emit("sendTechList", this.$refs.techSearchTable.getSelectionRows())
      this.store.commit("setTechSearchVisible", false)
    },
    handleSearch() {
      axios({
        url: '/api/medical_tech/query',
        method: 'post',
        data: this.search
      }).then(res => {
        this.tech_list = res.data.data
      }).catch(err => {
        console.log(err)
      }).then(() => {})
    }
  },
  props: [
    "store"
  ],
  computed: {
    techSearchVisible: {
      get() {
        return this.store.state.techSearchVisible
      },
      set(val) {
        this.store.commit("setTechSearchVisible", val)
      }
    }
  }
}
</script>

<style scoped>

</style>